<script type="text/javascript">
<#assign index=1>
var shortCutMenuArray = [{
<#list group_list as group>
<#assign x = index*200-200>
"t${group.orderNumber}":{"x":"-${x}px","y":"-84px","hx":"-${x}px","hy":"-112px","dx":"0px","dy":"-139px"}<#if group_list?size gt index>,</#if>
<#assign index=index+1>
</#list>
}];
<#assign index=1>
var tabsArray = [<#list group_list as group>"t${group.orderNumber}"<#if group_list?size gt index>,</#if><#assign index=index+1></#list>];
var origGroupId = '<#if tabGroup?? && tabGroup.id??>${tabGroup.id}</#if>';
var origIndex = '';
function processTab(groupId,index,funcId,load) {
    $('#groupId').val(groupId);
    $('#groupIndex').val(index);
    
    var url = TDQS.CONTEXT_PATH+'business/process?tdqssid='+TDQS.SESSION_ID+'&form.id=${form.id}&function.id='+funcId;
    <#if businessInstance?? && businessInstance.id??>
        if(load) {
            url += "&parentInstance.id=${businessInstance.id}";
        }
    </#if>
    url += '&date='+new Date().toLocaleString();
    if(load) {
        if(!$('#iframe_content'+index).attr('src') || $('#iframe_content'+index).attr('src')=='') {
            $('#iframe_content'+index).attr('src',url);
        }
    }
    $('table[tabletype="datagrid"]','#tab_t'+index).each(function(){
    	if(errorMark){
    	}else{
    		eval('gotoGrid'+$(this).attr('field')+'()');
    	}
    });
     $('a[class="button"]').each(function(){
    	if($(this).attr('groupIds') && $(this).attr('groupIds')!='') {
    		if($(this).attr('groupIds').indexOf(groupId)==-1) {
    			$(this).hide();
    		} else {
    			$(this).show();
    		}
    	}
    });
    HideOtherErrorMessage();   
    contentLayout(); 
}
var tabIndex = tabsArray.length;
<#list group_list as group>
	<#if group.orderNumber?? && group.orderNumber gt group_list?size>
	tabIndex = ${group.orderNumber};
	</#if>
</#list>
tabIndex = tabIndex+1;
function addTabPage(url,title){
	var openBoolean = false;
	$.each(tabsArray,function(index,value){
				if(value == "t"+tabIndex){
					openBoolean = true;
					$("#t"+tabIndex).click();
					$('#iframe_content'+tabIndex).attr('src',url);
					return;
				}
	});
	if(openBoolean){return;}
	var tabLi = $("<li/>").addClass("ui-state-default");
	tabLi.attr("id","t"+tabIndex);
	
	var cornerLeftBorder = '<div class="leftBorder" style="font-size: 1px;position:relative;float:left;left:0px;width:3px;height:26px"></div>';
			
	var liLeftcorner = $(cornerLeftBorder);
	
	var cornerRightBorder = '<div class="rightBorder" style="font-size: 1px;position:relative;float:left;right:0px;width:3px;height:26px">&nbsp;&nbsp;&nbsp;</div>';
			
	var liRightcorner = $(cornerRightBorder);
	
	var diva = $('<div class="contentInner" style="padding: 0px;line-height: 14px;height:25px;position:relative;float:left;border-top:1px solid #2b729a">');
	
	liLeftcorner.appendTo(tabLi);
	
	diva.appendTo(tabLi);
	
	
	var tabLia = $("<a/>");
	tabLia.appendTo(diva);
	var tabLiSpan = $("<span style='color:#FFFFFF'/>");
	tabLiSpan.text(title);
	tabLiSpan.appendTo(tabLia);
	liRightcorner.appendTo(tabLi);
	
	tabLi.bind("click",function(){
		if(!$('#iframe_content'+tabIndex).attr('src') || $('#iframe_content'+tabIndex).attr('src')=='') {
			$('#iframe_content'+tabIndex).attr('src',url);
		}
		$('a[class="button"]').each(function(){
	    	if($(this).attr('groupIds') && $(this).attr('groupIds')!='') {
	    		$(this).hide();
	    	}
	    });
	})
	var removeBut = $('<a style="padding:0px;"><img id="tabs_close_img'+tabIndex+'" src="./../theme/default/images/main/tabs_delete.png" class="tabs_close_img" style="top:0px;position:relative;"/></a>').appendTo(diva);
	removeBut.click(function(){
			if($.browser.msie&&($.browser.version == "6.0")){
				$("#t"+tabIndex).css('background-image','');
			}
			$("#t"+tabIndex).remove();
			$("#tab_t"+tabIndex).remove();
			$.each(tabsArray,function(index,value){
				if(value == "t"+tabIndex){
					tabsArray = tabsArray.removeAt(index+1);
				}
			})
			tabLi.unbind("click");
			shortCutMenuPosition(tabsArray);
			tabsLayout();
			loadTab();
	})
	tabLi.appendTo($("#ui-tabs"));
	
	var tabIframe = $("<iframe/>");
	tabIframe.attr("id","iframe_content"+tabIndex);
	tabIframe.attr("name","tab_"+tabIndex);
	tabIframe.attr("frameborder","0");
	tabIframe.css({"width":"100%","height":"100%"});
	
	var iframeTab = $("<div/>").addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");
	iframeTab.attr("id","tab_t"+tabIndex);
	iframeTab.css({"padding":"0"});
	
	tabIframe.appendTo(iframeTab);
	iframeTab.appendTo($("#tab_content_div"));
	tabsArray = tabsArray.insertAt(tabsArray.length,"t"+tabIndex);
	shortCutMenuPosition(tabsArray);
	tabsLayout();

	if($.browser.msie&&($.browser.version == "6.0")){
		setTimeout("iesix_tabLi_click()",0);
	}else{
		tabLi.click();
	}
}

function iesix_tabLi_click(){
	$("#t"+tabIndex).click();
}
$(function(){
    tabsLayout();
    <#if isHideButton?? && isHideButton=='1'>
    	$('a','#form1').each(function(){
    		$(this).removeAttr('onclick');
    		$(this).removeAttr('href');
    		$(this).attr('href','javascript:void(0);');
    	});
    	$('.content_s').hide();
    </#if>
});
function loadTab() {
    if($('#groupId').val()=='') {
        $('#'+tabsArray[0]).click();
    }
    else {
        var i = 0;
        <#list group_list as group>
            <#if group.group??>
                if($('#groupId').val()=='${group.group.id}') {
                    i = ${group.orderNumber};
                }
            </#if>
        </#list>
        if(i!=0) {
            $('#t'+i).click();
        }    
        else {
            $('#'+tabsArray[0]).click();
        }
    }
}
$(window).resize(tabsLayout);
function tabsLayout(){
    $(".ui-tabs-panel").css("height",window.document.body.clientHeight-$("#ui-tabs").height()-$(".serverErrorContainer").height()-46-12-4);
    $(".ui-tabs-panel").css("width",window.document.body.clientWidth);
    $("#tab_content_s").css("left",window.document.body.clientWidth/2-$("#tab_content_s").width()/2);
    $("#tabs_div").css("width",window.document.body.clientWidth);
    $("#tab_content_div").css("width",window.document.body.clientWidth);
    $("#tab_content_div").css("height",window.document.body.clientHeight-$("#ui-tabs").height()-$(".serverErrorContainer").height()-56);
    $("#tab_content").css("height",window.document.body.clientHeight-$("#ui-tabs").height()-$(".serverErrorContainer").height()-56-4);
    $("#tab_content").css("width",window.document.body.clientWidth);
    $(".serverErrorContainer").css("width",window.document.body.clientWidth);
    
    /*var obj=$("#tab_content_div")[0];  
    if($.browser.msie&&($.browser.version == "6.0" || $.browser.version == "7.0")){ 
    	if(obj.scrollHeight>obj.clientHeight||obj.offsetHeight>obj.clientHeight){ 
		    $(".ui-tabs-panel>table").each(function(){
		    	if($(this).hasClass("listviewTable")){
	    			$(this).css("width",window.document.body.clientWidth - 43);
	    		}else{
	    			$(this).css("width",window.document.body.clientWidth - 19);
		    	}
		    })
    	}else{
    		$(".ui-tabs-panel>table").each(function(){
		    	if($(this).hasClass("listviewTable")){
	    			$(this).css("width","99%");
	    		}else{
	    			$(this).css("width","100%");
		    	}
		    })
    	}	
    }*/
    
}

function contentLayout(){
	var errorContainerHeight = $(".serverErrorContainer").height();
	$(".ui-tabs-panel").css("height",window.document.body.clientHeight-$("#ui-tabs").height()-errorContainerHeight-46-12-4);
	$(".ui-tabs-panel").css("width",window.document.body.clientWidth);
    $("#tab_content").css("height",window.document.body.clientHeight-$("#ui-tabs").height()-errorContainerHeight-56-4);
    $("#tab_content_div").css("height",window.document.body.clientHeight-$("#ui-tabs").height()-errorContainerHeight-56);
    /*var obj=$("#tab_content_div")[0];   
    if($.browser.msie&&($.browser.version == "6.0" || $.browser.version == "7.0")){
    	if(obj.scrollHeight>obj.clientHeight||obj.offsetHeight>obj.clientHeight){ 
		    $(".ui-tabs-panel>table").each(function(){
		    	if($(this).hasClass("listviewTable")){
	    			$(this).css("width",window.document.body.clientWidth - 43);
	    		}else{
	    			$(this).css("width",window.document.body.clientWidth - 19);
		    	}
		    })
    	}else{
    		$(".ui-tabs-panel>table").each(function(){
		    	if($(this).hasClass("listviewTable")){
	    			$(this).css("width","99%");
	    		}else{
	    			$(this).css("width","100%");
		    	}
		    })
    	}
    
    }*/
}

function downLoadFunction(id,url) {
    if(url.indexOf('?')==-1) {
        url = url + '?';
    }
    var url = TDQS.CONTEXT_PATH+url+"&instanceId="+id+"&date="+new Date().toLocaleString();
    var frame = document.createElement("iframe");
    frame.src = url;
    frame.style.display = "none";
    document.body.appendChild(frame);
}


</script>   
<script type="text/javascript" src="./../script/page/config/tab.js"></script>
<div class="center_all">
 
    <div id="tabs_div" class="main_center_center_content_center ui-tabs ui-widget ui-widget-content" style="position:absolute;top:0px;padding:0px;border:0px;overflow:hidden">
        <ul id="ui-tabs" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header" style="-moz-border-radius-bottomleft: 0; -moz-border-radius-bottomright: 0;">
            <#list group_list as group>
                <li class="ui-state-default rounded {top transparent} rounded_by_jQuery_corners" id="t${group.orderNumber}" name="${group.group.id}" onClick="javascript:processTab('${group.group.id}','${group.orderNumber}','<#if group.group.function?? && group.group.function.id??>${group.group.function.id}</#if>',<#if group.content??>false<#else>true</#if>);return false;"  >
                <div class="leftBorder" style="font-size: 1px;background-image:url('./../theme/default/images/main/tab_left.png');position:relative;float:left;left:0px;width:3px;height:26px"></div>
                <div class="contentInner"  style="padding: 0px;line-height: 14px;height:25px;position:relative;float:left;border-top:1px solid #c2e2eb;background-image:url('./../theme/default/images/main/tabs.png');">
                <a><span style="color:#122664">${group.group.name}</span></a>
                </div>
                <div class="rightBorder" style="font-size: 1px;background-image:url('./../theme/default/images/main/tab_right.png');position:relative;float:left;right:0px;width:3px;height:26px">&nbsp;&nbsp;&nbsp;</div>
                </li>
            </#list>
        </ul>
        <div style="background-color:#2b729a;height:4px;overflow:hidden"></div>
        <!--jquery validator显示错误信息的容器 -->
        <div class="serverErrorContainer" style="position:relative;">
	        <div class="serverError">
	        <ol>
	            
	        </ol>
	        </div>
    
	        <div class="container">
	            <div class="searchButtonBox handleDiv" onclick="displayTable('handleDiv');return false;">
	            	<a href='javascript:void(0);' onclick="return false;" class="button switchOpen"  tabindex="-1" >
	    			<div style="border:1px solid #96d0d2;border-bottom:0px;position:relative;float:right;cursor:pointer;">
	    			<img id="handleDiv" src="./../theme/default/images/main/search/search_switch_open_normal.png" style="position:absolute;top:6px">
	    			<input type="button" style="margin-top:0px;width:16px;">
	    			</div>
	    			</a>
	            </div>
	            <div id="handleDiv_child" class="errorDIv" divAttend="attend">
	                <ol>
	                </ol>
	            </div>
	        </div>
   	 	</div>
   	 	<!-- end -->
        <div id="tab_content" style="height:100%;position:relative;">
        
        <#assign index=1>
        <form class="cmxform" id="form1" name="form1" method="post">
        <div id="tab_content_div" style="height:100%;position:absolute;overflow-y:auto;overflow-x:hidden;">
        
        <!-- end -->
        <div id="hiddenDiv">
		<input type="hidden" id="groupIndex" name="group.index" value="0" />
        <input type="hidden" id="functionId" name="function.id">
        <input type="hidden" id="isInnerEdit" name="isInnerEdit" <#if isInnerEdit??>value="${isInnerEdit}"</#if>>
        <input type="hidden" id="taskStatus" name="taskStatus" <#if businessInstance?? && businessInstance.status?? && businessInstance.status.id??>value="${businessInstance.status.id}"</#if>>
        <input type="hidden" id="formId" name="form.id" <#if form?? && form.id??>value="${form.id}"</#if>>
        <input type="hidden" id="groupId" name="group.id" <#if tabGroup?? && tabGroup.id??>value="${tabGroup.id}"</#if>>
        <input type="hidden" id="businessInstanceId" name="businessInstance.id" <#if businessInstance?? && businessInstance.id??>value="${businessInstance.id}"</#if>>
        <input type="hidden" id="businessInstanceIds" name="businessInstance.ids" <#if businessInstance?? && businessInstance.ids??>value="${businessInstance.ids}"</#if>>
        <#if businessInstance?? && businessInstance.parentInstance?? && (!businessInstance.id?? || (businessProcess.businessObj.isChild?? && businessProcess.businessObj.isChild=="1"))>
        <input type="hidden" id="parentInstanceId" name="parentInstance.id" value="${businessInstance.parentInstance.id}">
        </#if>
        <#if fieldMap??>
	    	<#list fieldMap?keys as key>
	    		<#if fieldMap[key].field??>
	    		<input type=hidden name="fieldMap['${key}'].field.id" <#if fieldMap[key].field.id??> value="${fieldMap[key].field.id}"</#if>>
				</#if>
				<input type=hidden id="${key}" name="fieldMap['${key}'].value" <#if fieldMap[key].value??> value="${fieldMap[key].value}"</#if>></input>
				<input type=hidden id="${key}" name="fieldMap['${key}'].entityId" <#if fieldMap[key].entityId??> value="${fieldMap[key].entityId}"</#if>></input>
	    	</#list>
	    </#if>
        </div>
        <#list group_list as group>
        <div id="tab_t${group.orderNumber}" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" style="padding:0px;"> 
        
        <#if group.content??>
        	<table cellspacing="0" cellpadding="0" class="listviewTable" width="100%">
                <tbody>
                <tr height="0" style="border:0px">
				    <td width="9%" style="border:0px"></td>
				    <td width="25%" style="border:0px"></td>
				    <td width="8%" style="border:0px"></td>
				    <td width="25%" style="border:0px"></td>
					<td width="8%" style="border:0px"></td>
					<td width="25%" style="border:0px"></td>
				</tr>
            	${group.content}
            	</tbody>
            </table>
        <#else>
            <#if group.group.children?? && group.group.children?size gt 0>
            		<#assign equalTable="1">
	                <#list group.group.children as child>
	                	<#assign showtable="0">
	                    <#if child?? && child.group?? && child.group.content??>
	                    <#if child.group.isShowTitle?default('1')=='1' && equalTable == '0'>
			            </tbody>
			            </table>
			            </td></tr></table>
			            </#if>
                        	<#if child.group.isShowTitle?default('1')=='1'>
                        	<#assign equalTable="1">
                        	<table cellspacing="0" cellpadding="0" width="100%" style="border:1px solid #c2e2eb;">
		                    <tbody>
                            <tr class="listviewHeader">
                                <th colspan="6">
                                	<div id="showYearFeeSpan" class="tableExtend tableOpen" style="position:relative;left:10px;"></div>
                                	<div style="position:relative;left:10px;float:left;line-height:17px;top:2px">
                                		<span style="margin-left:10px;"> ${child.group.name}</span></th>
                                	</div>	
                            </tr>
                            </tbody>
                            </table>
                            </#if>

                            <#if showtable?? && showtable == "0" && !(equalTable == '0')>
            				<#assign equalTable="0">
                            <table width="100%" cellspacing="0" cellpadding="0" style="padding-top:10px;padding-bottom: 10px;padding-left:10px;padding-right:20px;">
							<tbody><tr><td>
							<table cellspacing="0" cellpadding="0" width="100%" class="listviewTable">
					    	<tbody>
					    	<tr height="0" style="border:0px">
							    <td width="8%" style="border:0px"></td>
							    <td width="25%" style="border:0px"></td>
							    <td width="8%" style="border:0px"></td>
							    <td width="25%" style="border:0px"></td>
								<td width="8%" style="border:0px"></td>
								<td width="25%" style="border:0px"></td>
							</tr>
							</#if>
							
                            ${child.group.content}
                            
				            
				        </#if> 
				        
				        <#if child_has_next>
				            <#else>
				            <#assign equalTable="1">
				            </tbody>
				            </table>
				            </td></tr></table>
				            </#if>   
	                </#list>
                    
            <#else>
                <#if group.group.function?? && group.group.function.id??>
                    <iframe id="iframe_content${group.orderNumber}" name="tab_${group.orderNumber}" frameborder="0" style="width: 100%; height:100%"></iframe>  
                </#if>
            </#if>
        </#if>
        
        <#assign index=index+1>
        </div>
        </#list>
        </div>
        </form>
        </div>
    </div>
    <div style="background-image: url('./../theme/default/images/main/path_progress.png');width:100%;height:36px"></div>
</div>

 <div id="tab_content_s" class="content_s layout_div" style="height:46px;bottom:0px;position:absolute">
      <div style="width:700px;">
    <div class="buttonBox">
    <#if readonly?? && readonly=="1" && function??>
    		<a href="#" class="button" tabindex="-1" groupIds="<#list group_list as group><#if !group.group.function??>${group.group.id},</#if></#list>">
        	<input id="btnReadOnlyToEdit" type="button"   class="button" value="编辑" onclick="processEditFunction('${function.id}')"/>&nbsp;&nbsp;
        </a>
    </#if>
    <#list function_list as func>
        <#assign show="0">
        <#list feature_list as feature>
            <#if func.function.name==feature.code>
                <#if businessInstance.procDefId?? && businessInstance.status??>
                    <#if func.procDefId?? && func.status?? && func.procDefId==businessInstance.procDefId && func.status==businessInstance.status.id>
                        <#assign show="1">
                    </#if>
                <#else>
                    <#assign show="1">
                </#if>
            </#if>
        </#list>    
        <#if isInnerEdit?? && isInnerEdit=="1" && func.function.displayName?index_of("保存")==-1>
            	<#assign show="0">
            </#if>
        <#if show?? && show=="1">
	        <#if readonly?? && readonly=="1">
	        	<#if func?? && func.function?? && func.function.name?? && (func.function.displayName=="批量编辑" ||  func.function.displayName?index_of("导出")>=0 || func.function.displayName=="返回")>
		        	<a href="#" class="button" groupIds="<#if func.allowGroupIds??>${func.allowGroupIds}</#if>" tabindex="-1">
			        <input id="btn${func.function.name}" type="button"  class="button" value="<#if func.function?? && func.function.displayName??>${func.function.displayName}</#if>" onclick="process${form.id}('${func.function.id}','<#if func.function?? && func.function.type??>${func.function.type}</#if>',<#if func.function.messageType??>'${func.function.messageType}'<#else>'0'</#if>,<#if func.function.message??>'${func.function.message}'<#else>''</#if>,<#if func.function.clearSession??>'${func.function.clearSession}'<#else>'0'</#if>,<#if func.function.logicConfirmMessage??>'${func.function.logicConfirmMessage}'<#else>''</#if>,<#if func.function.logicBranchFunction??>'${func.function.logicBranchFunction.id}'<#else>''</#if>,<#if func.function.singleValidate??>'${func.function.singleValidate}'<#else>'0'</#if>)"/>&nbsp;&nbsp;
			        </a>
	        	</#if>
	        <#else>
	        	<#if func?? && func.function.displayName != "批量编辑">
		        <a href="#" class="button" groupIds="<#if func.allowGroupIds??>${func.allowGroupIds}</#if>" tabindex="-1">
		        <input id="btn${func.function.name}" type="button"  class="button" value="<#if func.function?? && func.function.displayName??>${func.function.displayName}</#if>" onclick="process${form.id}('${func.function.id}','<#if func.function?? && func.function.type??>${func.function.type}</#if>',<#if func.function.messageType??>'${func.function.messageType}'<#else>'0'</#if>,<#if func.function.message??>'${func.function.message}'<#else>''</#if>,<#if func.function.clearSession??>'${func.function.clearSession}'<#else>'0'</#if>,<#if func.function.logicConfirmMessage??>'${func.function.logicConfirmMessage}'<#else>''</#if>,<#if func.function.logicBranchFunction??>'${func.function.logicBranchFunction.id}'<#else>''</#if>,<#if func.function.singleValidate??>'${func.function.singleValidate}'<#else>'0'</#if>)"/>&nbsp;&nbsp;
		        </a>
		        </#if>  
	        </#if>
        </#if>
     </#list>
     <#if common_func_list??>
     <#list common_func_list as func>
        <#assign show="0">
        <#list feature_list as feature>
            <#if func.function.name==feature.code>
                <#assign show="1">
            </#if>
        </#list>    
        <#if isInnerEdit?? && isInnerEdit=="1" && func.function.displayName?index_of("保存")==-1>
            	<#assign show="0">
            </#if>
        <#if show?? && show=="1">
        	<#if readonly?? && readonly=="1">
	        	<#if func?? && func.function?? && func.function.name?? && (func.function.displayName=="批量编辑" ||  func.function.displayName?index_of("导出")>=0  || func.function.displayName=="返回")>
		        	<a href="#" class="button" groupIds="<#if func.allowGroupIds??>${func.allowGroupIds}</#if>" tabindex="-1">
			        <input id="btn${func.function.name}" type="button"  class="button" value="<#if func.function?? && func.function.displayName??>${func.function.displayName}</#if>" onclick="process${form.id}('${func.function.id}','<#if func.function?? && func.function.type??>${func.function.type}</#if>',<#if func.function.messageType??>'${func.function.messageType}'<#else>'0'</#if>,<#if func.function.message??>'${func.function.message}'<#else>''</#if>,<#if func.function.clearSession??>'${func.function.clearSession}'<#else>'0'</#if>,<#if func.function.logicConfirmMessage??>'${func.function.logicConfirmMessage}'<#else>''</#if>,<#if func.function.logicBranchFunction??>'${func.function.logicBranchFunction.id}'<#else>''</#if>,<#if func.function.singleValidate??>'${func.function.singleValidate}'<#else>'0'</#if>)"/>&nbsp;&nbsp;
			        </a>
	        	</#if>
	        <#else>	 
	               
	        	<#if func?? && func.function.displayName != "批量编辑">
			        <a href="#" class="button" groupIds="<#if func.allowGroupIds??>${func.allowGroupIds}</#if>" tabindex="-1">
			        <input id="btn${func.function.name}" type="button"  class="button" value="<#if func.function?? && func.function.displayName??>${func.function.displayName}</#if>" onclick="process${form.id}('${func.function.id}','<#if func.function?? && func.function.type??>${func.function.type}</#if>',<#if func.function.messageType??>'${func.function.messageType}'<#else>'0'</#if>,<#if func.function.message??>'${func.function.message}'<#else>''</#if>,<#if func.function.clearSession??>'${func.function.clearSession}'<#else>'0'</#if>,<#if func.function.logicConfirmMessage??>'${func.function.logicConfirmMessage}'<#else>''</#if>,<#if func.function.logicBranchFunction??>'${func.function.logicBranchFunction.id}'<#else>''</#if>,<#if func.function.singleValidate??>'${func.function.singleValidate}'<#else>'0'</#if>)"/>&nbsp;&nbsp;
			        </a>
		     	</#if>  
		        
	        </#if>
        </#if>
     </#list>
     </#if>
    </div>
    
        </div>
    
    
</div>
<script type="text/javascript" src="./../script/page/config/formvalidate.js"></script>
<script type="text/javascript" src="./../script/page/config/tdqs.validate.js"></script>
<script language="javascript">
var validator;
var errorMark = false;
function  HotFirstErrorMessage(){
		var b=true;
	$('#handleDiv_child label').each(function(i){
		if($(this).css("display") =="none"){
	  		return true;
		}
		var inputid =$(this).attr("for");
		$("#"+inputid).parents().each(function(i){
			if($(this).attr("id") != undefined && $(this).attr("id").indexOf("tab_t") >=0 ){					
				var id =$(this).attr("id").replace("tab_","");
				errorMark = false;
				$("#"+id).click();
				b= false;
				return false;
				
			}
		});
		return b;
	});
}

function HideOtherErrorMessage() {
	var currentgroupid = $('#groupId').val();
	var currentgroupindex = $('#groupIndex').val();
	var cv = $('#tab_t'+currentgroupindex);
	$('#handleDiv_child label').each(function(i){
		var inputid =$(this).attr("for");		
		var b =true;
		$("#"+inputid).parents().each(function(i){
			if($(this).attr("id") == cv.attr("id") ){
				b =false;
				return false;
			}
		});
		if(b){
			$(this).parent().hide();
		}else{	
			if($(this).css("display") !="none"){
				$(this).parent().show();	
			}
		}
	});
}

function processEditFunction(funcId) {
    disabledAllButton();
	var url = TDQS.CONTEXT_PATH+"business/process?tdqssid="+TDQS.SESSION_ID+"&function.id="+funcId+"&businessInstance.id="+$('#businessInstanceId').val()+"&taskStatus="+$('#taskStatus').val()+"&form.id="+$('#formId').val()+"&group.id="+$('#groupId').val()+"&isInnerEdit="+$('#isInnerEdit').val();
	url += "&date="+new Date().toLocaleString();
	document.location.href = url;
}

function process${form.id}(funcId,type,messageType,message,clearSession,logicMessage,logicBranchFuncId,singleValidate) {

  	 var validteType =type;
  	 left_current_page = true;
  	 if(type =='5'){
  	 type ='3';
  	 }
    if(validator && type == '3') {
			validator.type =validteType;
			if(singleValidate=='1') {
				$('#form1').removeValidator();
				validatorForm($('#tab_t'+$('#groupIndex').val()));
			}
			if(!validator.form()) {
				left_current_page = false;
				HotFirstErrorMessage();
				if(singleValidate=='1') {
					$('#form1').removeValidator();
					validatorForm();
				}
				return false;
			}
	 }
  	 
	var url = TDQS.CONTEXT_PATH+'business/process';
	if(!message||message=='') {
		message = '确定要执行操作吗？';
    }
    

    
    if(messageType && messageType=='1') {
		
		jConfirm(message, '确认对话框 ', function(r) {
			if(r){
				if(logicMessage && logicMessage!='' && logicBranchFuncId && logicBranchFuncId!='') {
					jYesOrNoConfirm(logicMessage, '确认对话框 ', function(r) {
						if(!r) {
							funcId = logicBranchFuncId;
						}
						if(type && type=='3') {
                            disabledAllButton();
							block($(document.body),"数据提交中，请稍候...");
	        		if(clearSession=='1') {
				    	url += '?tdqssid='+TDQS.SESSION_ID+'&clearSession='+clearSession;
				    }
	                ${"$('#functionId')"}.val(funcId);
	                ${"$('#form1')"}.attr('action',url);
	                if(singleValidate=='1') {
	                	$('input',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                	$('select',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                	$('textarea',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                }
	                ${"$('#form1')"}.submit();
	            } else if(type && type=='6') {
			    	${"$('#functionId')"}.val(funcId);
			    	exportData();
				} else {
                    disabledAllButton();
	                url += "?tdqssid="+TDQS.SESSION_ID+"&function.id="+funcId+"&businessInstance.id="+$('#businessInstanceId').val()+"&taskStatus="+$('#taskStatus').val()+"&form.id="+$('#formId').val();
	                <#if businessInstance?? && businessInstance.parentInstance?? && (!businessInstance.id?? || (businessProcess.businessObj.isChild?? && businessProcess.businessObj.isChild=="1"))>
	                url += "&parentInstance.id="+$('#parentInstanceId').val();
	                </#if>
	                if(clearSession=='1') {
				    	url += '&clearSession='+clearSession;
				    }
	                url += "&date="+new Date().toLocaleString();
	                document.location.href = url;
	            }
					});
				} else {
	        	if(type && type=='3') {
                    disabledAllButton();
	        		block($(document.body),"数据提交中，请稍候...");
	        		if(clearSession=='1') {
				    	url += '?tdqssid='+TDQS.SESSION_ID+'&clearSession='+clearSession;
				    }
	                ${"$('#functionId')"}.val(funcId);
	                ${"$('#form1')"}.attr('action',url);
	                if(singleValidate=='1') {
	                	$('input',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                	$('select',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                	$('textarea',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                }
	                ${"$('#form1')"}.submit();
	            } else if(type && type=='6') {
			    	${"$('#functionId')"}.val(funcId);
			    	left_current_page = false;
			    	exportData();
				} else {
                    disabledAllButton();
	                url += "?tdqssid="+TDQS.SESSION_ID+"&function.id="+funcId+"&businessInstance.id="+$('#businessInstanceId').val()+"&taskStatus="+$('#taskStatus').val()+"&form.id="+$('#formId').val();
	                <#if businessInstance?? && businessInstance.parentInstance?? && (!businessInstance.id?? || (businessProcess.businessObj.isChild?? && businessProcess.businessObj.isChild=="1"))>
	                url += "&parentInstance.id="+$('#parentInstanceId').val();
	                </#if>
	                if(clearSession=='1') {
				    	url += '&clearSession='+clearSession;
				    }
	                url += "&date="+new Date().toLocaleString();
	                document.location.href = url;
	            } 
	          }
	        }else{
	        	left_current_page = false;
	            return false;
	        }
		});
    } else {
        if(type && type=='3') {
            disabledAllButton();
        	block($(document.body),"数据提交中，请稍候...");
        	if(clearSession=='1') {
		    	url += '?tdqssid='+TDQS.SESSION_ID+'&clearSession='+clearSession;
		    }
            ${"$('#functionId')"}.val(funcId);
            ${"$('#form1')"}.attr('action',url);
            if(singleValidate=='1') {
	                	$('input',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                	$('select',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                	$('textarea',$('.ui-tabs-panel').not('#tab_t'+$('#groupIndex').val())).each(function(){
	                		this.disabled = "disabled";
	                	});
	                }
            ${"$('#form1')"}.submit();
        } else if(type && type=='6') {
			    	${"$('#functionId')"}.val(funcId);
			    	left_current_page = false;
			    	exportData();
		} else if(type && type=='4') {
        	var currentGroupId = $('#groupId').val();
        	var currentIndex = $('#groupIndex').val();
        	$('#groupId').val(origGroupId);
        	$('#groupIndex').val(origIndex);
        	$('#functionId').val('');
			if(serializeformData == $("#form1").serialize()) {
                disabledAllButton();
				$('#groupId').val(currentGroupId);
				$('#groupIndex').val(currentIndex);
				url += "?tdqssid="+TDQS.SESSION_ID+"&function.id="+funcId+"&businessInstance.id="+$('#businessInstanceId').val()+"&taskStatus="+$('#taskStatus').val()+"&form.id="+$('#formId').val();
                <#if businessInstance?? && businessInstance.parentInstance?? && (!businessInstance.id?? || (businessProcess.businessObj.isChild?? && businessProcess.businessObj.isChild=="1"))>
                url += "&parentInstance.id="+$('#parentInstanceId').val();
                </#if>
                if(clearSession=='1') {
			    	url += '&clearSession='+clearSession;
			    }
                url += "&date="+new Date().toLocaleString();
				document.location.href = url;
			} else {		
				$('#groupId').val(currentGroupId);
				jConfirm('当前页面内容已有修改，确认要返回吗？', '确认对话框 ', function(r) {
					if(r){
                        disabledAllButton();
						url += "?tdqssid="+TDQS.SESSION_ID+"&function.id="+funcId+"&businessInstance.id="+$('#businessInstanceId').val()+"&taskStatus="+$('#taskStatus').val()+"&form.id="+$('#formId').val();
                        <#if businessInstance?? && businessInstance.parentInstance?? && (!businessInstance.id?? || (businessProcess.businessObj.isChild?? && businessProcess.businessObj.isChild=="1"))>
                        url += "&parentInstance.id="+$('#parentInstanceId').val();
                        </#if>
                        if(clearSession=='1') {
					    	url += '&clearSession='+clearSession;
					    }
                        url += "&date="+new Date().toLocaleString();
						document.location.href = url;						
					}else{
						left_current_page = false;
						return false;
					}
				});
			} 
        }
        else {
            disabledAllButton();
            url += "?tdqssid="+TDQS.SESSION_ID+"&function.id="+funcId+"&businessInstance.id="+$('#businessInstanceId').val()+"&taskStatus="+$('#taskStatus').val()+"&form.id="+$('#formId').val();
            <#if businessInstance?? && businessInstance.parentInstance?? && (!businessInstance.id?? || (businessProcess.businessObj.isChild?? && businessProcess.businessObj.isChild=="1"))>
            url += "&parentInstance.id="+$('#parentInstanceId').val();
            </#if>
            if(clearSession=='1') {
		    	url += '&clearSession='+clearSession;
		    }
            url += "&date="+new Date().toLocaleString();
            document.location.href = url;
        }
    }
}

function exportData() {
	$('#exportFrame').remove();
	var frame = document.createElement('iframe');
	frame.id='exportFrame';
	frame.name='exportFrame';
	frame.style.display='none';
	document.body.appendChild(frame);
	var doc = document.getElementById('exportFrame').contentWindow.document;
	doc.write('<html><body></body></html>');
	var form = doc.createElement("form");
	form.action=TDQS.CONTEXT_PATH+'business/process?tdqssid='+TDQS.SESSION_ID;
	$(form).attr('method','post');
	var div = doc.createElement("div");
	div.style.display = "none";
	div.innerHTML=$('#hiddenDiv').html();
	$(form).append(div);
	doc.body.appendChild(form);
	form.submit();
}

<#if form.validation??>
    ${form.validation}
</#if>

$(document).ready(function(){
	serializeformData=$("#form1").serialize();
	origGroupId = $('#groupId').val();
	origIndex = $('#groupIndex').val();
	$("#form1 .tableExtend").each(function(i){
    	$(this).click(function(){
    		var objHeard = $(this);
			var currentTable = $($(this).parents("table").get(0));
			var operTable = $(currentTable).next("table");
    		
    		if($(objHeard).hasClass("tableOpen")){
    			$(operTable).hide();
    			$(objHeard).removeClass("tableOpen");
    			$(objHeard).addClass("tableClose");
    		}else{
    			$(operTable).show();
    			$(objHeard).removeClass("tableClose");
				$(objHeard).addClass("tableOpen");
    		}
    		
    	})
    })
});
</script>  